﻿Imports System
Imports System.IO
Imports System.Data.OleDb
Imports System.Data
Namespace Arwani
    Partial Class Backend_ManageDivision
        Inherits System.Web.UI.Page

        Protected Sub lnkAddNewDivision_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkAddNewDivision.Click
            Response.Redirect("AddDivision.aspx")
        End Sub

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If (Session("ADMIN_USER") IsNot Nothing) Then
                If Page.IsPostBack = True Then Exit Sub
                Call loadData()
            Else
                Response.Redirect("Default.aspx")
            End If

        End Sub
        Public Sub loadData()
            Dim arwCon As New ArwaniController
            Dim strQ As String = "select * from division"
            Dim dtTable As DataTable = arwCon.ExecuteQuery(strQ)
            Me.dgDivision.DataSource = dtTable
            Me.dgDivision.DataBind()

        End Sub
        Public Function getImage(ByVal imgSrc As String) As String
            Dim strReturn As String = "../images/main_banner.png"
            If File.Exists(Server.MapPath("../Divisions/" & "Thumb_" & imgSrc)) Then
                strReturn = "../Divisions/" & "Thumb_" & imgSrc
            End If
            Return strReturn
        End Function
        Public Function getOtherImage(ByVal imgSrc As String) As String
            Dim strReturn As String = "../images/main_banner.png"
            If File.Exists(Server.MapPath("../Divisions/" & imgSrc)) Then
                strReturn = "../Divisions/" & imgSrc
            End If
            Return strReturn
        End Function
        Protected Sub dgDivision_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgDivision.ItemCommand
            If e.CommandName = "Slider" Then
                Response.Redirect("AddNewSlider.aspx?divid=" & CInt(e.CommandArgument))
            ElseIf e.CommandName = "Category" Then
                Response.Redirect("ManageCategory.aspx?divid=" & CInt(e.CommandArgument))
            ElseIf e.CommandName = "Edit" Then
                Response.Redirect("AddDivision.aspx?divid=" & CInt(e.CommandArgument))
            ElseIf e.CommandName = "Brands" Then
                Response.Redirect("ManageBrands.aspx?divid=" & CInt(e.CommandArgument))
            End If

        End Sub
    End Class
End Namespace